Skip to main content

All Questions

Tagged with
0votes
1answer
184views

Elegant way in C to store many parameters with default value and current value in embedded flash

I'm programming an embedded system that has a number of user configurable parameters, which are stored in flash memory. I have to store a default value for each parameter as well as the user settings. ...
jusaca's user avatar
0votes
2answers
685views

How to create an interface in C that can work on two identical structs with differently named fields

Question Background Consider a scenario in which I have two structs. Both consist of three fields for doubles. The only difference is the names used to refer to these fields. The first struct is for ...
Shadow43375's user avatar
0votes
1answer
238views

Should all structures be ADTs?

Is there any specific category an ADT must be in? I'm struggling to find out how best to represent objects in the program for example: As a record: struct Person { int age }; Or as an ADT: struct ...
user avatar
0votes
1answer
83views

Custom datatype and their constructors - should you clone, or just copy?

Suppose we have the following C snippet, implementing a tree data structure: typedef struct node { char* data; struct node** children; unsigned int num_children; } node; Then we could ...
steeps's user avatar
2votes
1answer
5kviews

How to separate public and private headers when internal data structures are private?

When developing a shared library in C, it is common to separate the "public" headers from the "private" headers. The public headers contain all the functions and types that are ...
Woodrow Barlow's user avatar
-3votes
1answer
321views

Data structures or coding styles in C++ for avoiding long elseif chain when parsing?

Lately I have created some small parsers of data. My initial code structure // more cases here ... else if(!strcmp(X,"somekey")){ // Parse according to "somekey" behavior. } // ...
mathreadler's user avatar
-2votes
2answers
182views

What is the correct use of -> operator when working with pointers?

I'm pretty new with C so I have encountered many doubts with pointers. I've already search a lot about this but there are some things that still are not clear for me, and I also think this will help ...
Nicolas Bazan's user avatar
0votes
1answer
2kviews

Why would you make a struct without typedef?

Since I cut my teeth on code with OO, I’m biased toward using structs as classes without methods. However, there’s probably a good reason that typedef isn’t the default behavior of struct. What is it?
JohnnyApplesauce's user avatar
4votes
1answer
118views

Is a generic data structure customary for use in a self contained program, or can I duplicate source files?

I have a project that does some Dijkstra searches on a graph, I implemented a red-black tree and priority queue that I use for the nodes, however I also need the same data structures for other things ...
Materia Gravis's user avatar
0votes
1answer
667views

Subdomain matching

I am working on a small plugin for a DNS server. I have a static list of domain (sometimes subdomains too) names: gaming.xyz.com facebook.com mail.example.com blog.example.com I want to check if a ...
psy's user avatar
  • 137
1vote
1answer
169views

Find a string in list of strings

Background: I am writing an application for a small embedded device. There is a static list of strings: currently about 500 strings and string length is 12 characters on average. The list might ...
psy's user avatar
  • 137
-3votes
2answers
11kviews

Why we use top== -1 for implementation of stack using simple array?

I am a newbie at data structures. I have read an implementation of a stack using a simple array. The algorithm for this implementation is presented below. Stack implementation in terms of an array ...
geek's user avatar
0votes
1answer
1kviews

Computing the shortest path in a labyrinth

I'm currently trying to map how to make a good algorithm that won't have issues to find the shortest path. The labyrinth consists of an X and Y dimensions as input; However, the labyrinth will ...
Zeid Tisnes's user avatar
60votes
6answers
40kviews

Why do many functions that return structures in C, actually return pointers to structures?

What is the advantage of returning a pointer to a structure as opposed to returning the whole structure in the return statement of the function? I am talking about functions like fopen and other low ...
yoyo_fun's user avatar
1vote
1answer
2kviews

What is the advantage of POSIX queue or just normal data structure queue?

I'm programming with the embedded device running Linux, where memory is less, I just have 64MB flash only. I planned to use queues for the thread communication. In which I came across with using ...
danglingpointer's user avatar

153050per page
close